package edu.hawaii.myisern.model;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

/**
 * Tests the logging utility.
 * 
 * @author Randy Cox
 * 
 */
public class TestLog {

  /**
   * Tests the log class.
   */
  @Test
  public void testLog() {
    Boolean saveVerbose = Log.verbose;
    Boolean saveSevereOnly = Log.severeOnly;
    Log.verbose = true;
    Log.severeOnly = false;
    Log.clear();
    String testInfo = "Test infomational message.";
    String testError = "Test error message.";
    Log.enter(testInfo);
    Log.error(testError);
    String result = Utility.readTextData(Log.LOG_FILENAME);
    assertTrue("Test log file contents.", result.contains(testInfo));
    assertTrue("Test log file contents.", result.contains(testError));
    Log.verbose = saveVerbose;
    Log.severeOnly = saveSevereOnly;
  }

  /**
   * Tests the log class.
   */
  @Test
  public void testConstructor() {
    Log log = new Log();
    assertNotNull("Test constructor.", log);
  }

}
